﻿using System;
using System.Collections.Generic;
using NHibernate.Validator.Constraints;

namespace DataStore.Domain
{
    /// <summary>
    /// Company data
    /// </summary>
    [Serializable]
    public class Company
    {
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        public virtual Guid Id { get; set; }
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        [NotNullNotEmpty(Message = "Name cannot be empty")]
        public virtual string Name { get; set; }
        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        /// <value>The type.</value>
        public virtual CompanyType Type { get; set; }
        /// <summary>
        /// Gets or sets the date of foundation.
        /// </summary>
        /// <value>The date of foundation.</value>
        public virtual DateTime? Founded { get; set; }
        /// <summary>
        /// Gets or sets the founders.
        /// </summary>
        /// <value>The founders.</value>
        public virtual ICollection<Person> Employees { get; set; }
        /// <summary>
        /// Gets or sets the industry.
        /// </summary>
        /// <value>The industry.</value>
        public virtual string Industry { get; set; }
        /// <summary>
        /// Gets or sets the links.
        /// </summary>
        /// <value>The links.</value>
        public virtual ICollection<Link> Links { get; set; }
        /// <summary>
        /// Gets or sets the address.
        /// </summary>
        /// <value>The address.</value>
        public virtual ICollection<Address> Addresses { get; set; }

        public Company()
        {}

        public Company(Company company)
        {
            Update(company);
        }

        public virtual void Update(Company company)
        {
            Name = company.Name;
            Type = company.Type;
            Founded = company.Founded;
            Employees = company.Employees;
            Industry = company.Industry;
            Links = company.Links;
            Addresses = company.Addresses;
        }
    }
}
